﻿@model IEnumerable<Product>
@{
    ViewBag.Title = "产品列表";
}

<style>
    table {
        width: 100%;
        border-collapse: collapse;
    }
    th, td {
        padding: 10px;
        text-align: left;
        border: 1px solid #ddd;
    }
    th {
        background-color: #f2f2f2;
    }
    tr:nth-child(even) {
        background-color: #f9f9f9;
    }
    tr:hover {
        background-color: #f1f1f1;
    }

</style>

<table>
    <thead>
        <tr>
            <th>产品ID</th>
            <th>产品名称</th>
            <th>产品描述</th>
            <th>价格</th>
            <th>创建时间</th>
        </tr>
    </thead>
    <tbody>
        @if (Model != null && Model.Any())
        {
            foreach (var product in Model)
            {
                <tr>
                    <td>@product.ProductId</td>
                    <td>@product.ProductName</td>
                    <td>@product.Description</td>
                    <td>@product.Price.ToString("C")</td> 
                    <td>@product.CreatedDate</td> 
                </tr>
            }
        }
        else
        {
            <tr><td colspan="5">无产品数据</td></tr> 
        }
    </tbody>
</table>